<template>
	<view class="page b-bg">
		<view id='upLoad'>
			<!-- <view class="info block">
				<view class="title">
					投稿说明
				</view>
				<view class="f-title">
					面向学生
				</view>
				<view class="infoTextBox">
					<view class="infoText" :class="{close:open_off}">
						<div v-html="dec.condition_description"></div>
					</view>
					<view class="toggleBtn">
						 <view class="icon-warning" @tap="toggleBtn">
							 <text v-show="open_off">展开详情</text>
							 <text v-show="!open_off">收起详情</text>
						</view>
					</view>
				</view>
			</view> -->
			<view class="roleBox block" v-show="step == 1">
				<view class="title">
					投稿角色
				</view>
				<view class="roles">
					<view class="role" v-for="(item,index) in role_data" :key="index" @tap="changeRoles(index)" :class="{active:index == currentRoloIndex}">
						{{item.text}}
					</view>
				</view>
			</view>
			<view class="roleBox block" v-show="step == 2">
				<view class="title">
					作品类型
				</view>
				<view class="roles">
					<view class="role"  :class="{active:index == currentWorkTypeIndex}" @tap="changeUpTab(index)" v-for="(item,index) in upTypeData" :key="index">
						{{item.text}}
					</view>
				</view>
			</view>
		    <view class="inputName block" v-show="step == 2">
				<view class="title">
					作品名称
				</view>
				<view class="input add-form">
					<view class="ad-name-inputBox">
						<uni-easyinput type="text"
						:clear="false"
						clearSize='0'
						v-model="workName"
						placeholder="请输入作品名称" />
					</view>
				</view>
			</view>
			<view class="upBox block" v-show="step == 2 && category.mp4">
				<div class="title">
					上传视频 <span style="color:#999"></span>
				</div>
				<div class="upImgBox">
					<!-- <div id="upImgBtn">
						<img src="../../static/img/default.png" class="default" alt="">
					</div>
					<div id="upImgBtnlist">
						
					</div> -->
					<!-- <ossupload></ossupload> -->
					<ossupload btnId="upVideo" @getList="getList" ref="oss"></ossupload>
				</div>
			</view>
			<view class="upBox block" v-show="step == 2 && category.image">
				<div class="title">
					上传图片<span style="color:#999">( 最多传5张,支持png,jpg )</span>
				</div>
				<div class="upImgBox">
					<ossupload btnId="upImg" @getList="getList" ref="oss"></ossupload>
				</div>
			</view>
			<view class="upBox block" v-show="step == 2 && category.docs">
				<div class="title">
					上传文档<span style="color:#999"> (最多传5个)</span>
				</div>
				<div class="upImgBox">
					<ossupload btnId="upWord" @getList="getList" ref="oss"></ossupload>
				</div>
			</view>
			 <view class="join block" v-show="step == 2">
			 	<view class="title">
			 		补充信息
			 	</view>
			 	<view class="tab2 add-form" v-show="step == 2" >
			 		<view class="add-row" v-show ="role_type == 1">
			 				<view class="ad-label">
			 					<text class="icon-warning">*</text>
			 					指导老师
			 				</view>
			 				<view class="ad-inputBox">
			 					<uni-easyinput type="text"
			 					:clear="false"
			 					clearSize='0'
			 					v-model="address"
			 					placeholder="请输入老师姓名" />
			 				</view>
			 	     </view>
			 	<view class="add-row school" style="margin-bottom: 15rpx;" v-show="step == 2">
			 				<view class="ad-label">
			 					<text class="icon-warning">*</text>
			 					手机号码
			 				</view>
			 				<view class="ad-inputBox">
			 					<uni-easyinput type="text"
			 					:clear="false"
			 					clearSize='0'
			 					v-model="phone"
			 					placeholder="便于主办方与您联系,不对外公开" />
			 				</view>
			 	</view>
			 <!-- 	 <view class="add-row school" style="margin-bottom: 15rpx;" v-show="!is_uni && role_type !== 1">
			 					<view class="ad-label">
			 						<text class="icon-warning">*</text>
			 						学校/工作单位
			 					</view>
			 					<view class="ad-inputBox">
			 						<uni-easyinput type="text"
			 						:clear="false"
			 						clearSize='0'
			 						v-model="form_data.school3"
			 						placeholder="学校/工作单位" />
			 				   </view>
			 	 </view> -->
			 	</view>
			 	</view>
			<view class="join block" v-if="step == 1">
				<view class="title">
					参与者信息
				</view>
				<view class="over" v-if="role_type == 99">
					您已经投稿成功了！
				</view>
				<view class="btnbox" v-if="role_type == 1">
					<view>请选择学生参与活动</view>
					<view @tap="addStudent">
						 <img src="../../static/img/add.png"  class="addICon"alt="">
						 <text>添加学生</text>
					 </view>
				</view>
				<view class="tab1" v-if="step == 1 && role_type == 1">
                  <view class="stus">
						 <view class="stu" @tap="choice(index,item.is_exist)" v-for="(item,index) in studata" :key="index" :class="{active:currentStu == index}">
							 <view class="st-title">
								 <view class="name">{{item.student_name}}</view>
								 <view class="ycy" v-show="item.is_exist">已参与</view>
								 <view class="del" @tap.stop="deletStu(index)" v-show="item.is_all_exist !== 1">
								 	 <text class="iconfont icon-shanchu icon-warning"></text>
								 </view>
							 </view>
							 <view class="textell">地区：{{item.county_name}}</view>
							 <view class="textell">学校：{{item.school_name}}</view>
							 <view class="textell">班级：{{item.class_name}}</view>
						 </view>
				  </view>
			    </view>
				<view class="tab2 add-form"  v-if="step == 1 && role_type == 2 && !is_uni">
					<view class="add-row">
							<view class="ad-label">
								<text class="icon-warning">*</text>
								姓名
							</view>
							<view class="ad-inputBox">
								<uni-easyinput type="text"
								:clear="false"
								clearSize='0'
								v-model="form_data.name"
								placeholder="输入投稿人姓名" />
							</view>
				     </view>
				<view class="add-row">
							<view class="ad-label">
								<text class="icon-warning">*</text>
								地区
							</view>
							<view class="ad-inputBox">
							 <uni-data-select
								  v-model="form_data.city_id"
								  :localdata="rangeCity"
								  :clear="false"
								  @change="changeCity"
								></uni-data-select>
							</view>
				</view>
				<view class="add-row">
							<view class="ad-label">
								<text class="icon-warning">*</text>
								区县
							</view>
							<view class="ad-inputBox">
							 <uni-data-select
								  v-model="form_data.county_id"
								  :localdata="rangeCounty"
								  :clear="false"
								   @change="changeCounty"
								></uni-data-select>
							</view>
				</view>
				<view class="add-row school" style="margin-bottom: 15rpx;">
							<view class="ad-label">
								<text class="icon-warning">*</text>
								学校/工作单位
							</view>
							<view class="ad-inputBox">
								<uni-data-select
								  v-model="form_data.school_id"
								  :localdata="rangeSchool"
								  :clear="false"
								></uni-data-select>
							</view>
				</view>
				</view>
				<view class="tab2 add-form"  v-if="step == 1 && role_type == 2 && is_uni">
					<view class="add-row">
							<view class="ad-label">
								<text class="icon-warning">*</text>
								姓名
							</view>
							<view class="ad-inputBox">
								<uni-easyinput type="text"
								:clear="false"
								clearSize='0'
								v-model="form_data.bigname"
								placeholder="输入投稿人姓名" />
							</view>
				     </view>
				<view class="add-row">
						<view class="ad-label">
							<text class="icon-warning">*</text>
							地区
						</view>
						<view class="ad-inputBox">
						 <uni-data-select
							  v-model="form_data.city_big_id"
							  :localdata="rangeBigCity"
							  :clear="false"
							  @change="changeBigCity"
							></uni-data-select>
						</view>
				</view>
				<view class="add-row">
							<view class="ad-label">
								<text class="icon-warning">*</text>
								学校
							</view>
							<view class="ad-inputBox">
							 <uni-data-select
								  v-model="form_data.school_big_id"
								  :localdata="rangeBigSchool"
								  :clear="false"
								></uni-data-select>
							</view>
				</view>
				<view class="add-row">
						<view class="ad-label">
							院系
						</view>
						<view class="ad-inputBox">
							<uni-easyinput type="text"
							:clear="false"
							clearSize='0'
							v-model="form_data.role_colleges"
							placeholder="输入投稿人院系" />
						</view>
				 </view>
				 <view class="add-row">
				 		<view class="ad-label">
				 			专业
				 		</view>
				 		<view class="ad-inputBox">
				 			<uni-easyinput type="text"
				 			:clear="false"
				 			clearSize='0'
				 			v-model="form_data.role_major"
				 			placeholder="输入投稿人专业" />
				 		</view>
				  </view>
				
				</view>
				<view class="tab2 add-form"  v-if="step == 1 && role_type == 3 && !is_uni">
									<view class="add-row">
											<view class="ad-label">
												<text class="icon-warning">*</text>
												姓名
											</view>
											<view class="ad-inputBox">
												<uni-easyinput type="text"
												:clear="false"
												clearSize='0'
												v-model="form_data.name"
												placeholder="输入投稿人姓名" />
											</view>
								     </view>
								<view class="add-row">
											<view class="ad-label">
												<text class="icon-warning">*</text>
												地区
											</view>
											<view class="ad-inputBox">
											 <uni-data-select
												  v-model="form_data.city_id"
												  :localdata="rangeCity"
												  :clear="false"
												  :disabled="cityDisable"
												  @change="changeCity"
												></uni-data-select>
											</view>
								</view>
								<view class="add-row">
											<view class="ad-label">
												<text class="icon-warning">*</text>
												区县
											</view>
											<view class="ad-inputBox">
											 <uni-data-select
												  v-model="form_data.county_id"
												  :localdata="rangeCounty"
												  :clear="false"
												   :disabled="countyDisable"
												   @change="changeCounty"
												></uni-data-select>
											</view>
								</view>
								<view class="add-row school" style="margin-bottom: 15rpx;background-color: red;">
											<view class="ad-label">
												<text class="icon-warning">*</text>
												学校/工作单位
											</view>
											<view class="ad-inputBox">
												<uni-easyinput type="text"
												:clear="false"
												clearSize='0'
												v-model="form_data.school3"
												placeholder="请输入" />
											</view>
								</view>
					</view>
				</view>
				<view class="nextBtn" v-show="step == 1 && role_type != 99">
					<view class="bt bt-a" @tap="nextStep">下一步</view>
				</view>
				<view class="nextBtnTwo" v-if="step == 2">
					<view class="bt" @tap="blackStep">返回上一步</view>
					<view class="bt bt-a" @tap="allSubmit">提交</view>
				</view>
			</view>
	</view>
		
		
</template>

<script>
	var Phone = /^[1][3,4,5,7,8,9][0-9]{9}$/
	import mixin from '@/util/mixin.js';
	import plupload from "plupload";
	export default {
		mixins:[mixin],
		data() {
			return {
				upTypeData:[],
				role_data:[],
				studata:[],
				agree:false,
				curStu:NaN,
				dec:'',
				currentRoloIndex:0,
				currentWorkTypeIndex:0,
				currentStu:0,
				category:{
					docs:0,
					image:0,
					mp4:0
				},
				open_off:true,
				cityDisable:false,
				countyDisable:false,
				step:1,
				role_type:1,
				form_data:{
					city_id:"",
					county_id:"",
					school_id:"",
					school_big_id:"",
					school3:"",
					name:'',
					classname:"",
					role_id:"",
					city_big_id:"",
					role_colleges:'',
					role_major:""
				},
				sub_data:{
					upType:'video',
					title:'',
					description:'',
					tel:''
				},
				postData:{
					activity_id:3,
					ext:"mp4",
					role:1,
					student_id:0
				},
				address:"",
				phone:'',
				workName:'',
				is_uni:false,
				rangeCity:[],
				rangeCounty:[],
				rangeSchool:[],
				rangeBigCity:[],
				rangeBigCounty:[],
				rangeBigSchool:[],
				stu1:"",
				stu2:"",
				stu3:"",
				school:"",
				schoolId:"",
				upValue:{
					img:[],
					mp4:[],
					word:[]
				},
				goid:""
			};
		},
		onShow() {
			const mytoken = uni.getStorageSync('token'); 
			if (!mytoken) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			} else {
				this.getStudent();
			}
			
		},
		onLoad(options) {
			this.goid = options.id;
			if(options.token) {
				//获取token
				//判断内存里是否有token
				const mytoken = uni.getStorageSync('token');
				if(mytoken) {
					this.getRole();
					this.getCategory();
					this.getAra();
					this.getAraBig();
					this.getInfor();
					this.getdec();
				} else {
					this.getToken(options.token);
				}
			} else {
				this.getRole();
				this.getCategory();
				this.getAra();
				this.getAraBig();
				this.getdec();
			}
		},
		methods:{	
			async getdec() {
					const res = await this.$httpPub({
						  url:'activity/' + this.goid,
						  method:'get',
						  data:{}
					})
				   this.dec =res;	
				   
				   //测试
				   // this.dec.level = 3;
				   // this.dec.city_id = 420500;
				   // this.dec.county_id = 420528;
				
				 if(this.dec.level == 2) {
					  this.cityDisable = true;
					  this.form_data.city_id = this.dec.city_id;
					  this.changeCity(this.dec.city_id);
				 }
				 
				 if(this.dec.level == 3) {
					 this.cityDisable = true;
				 	 this.countyDisable = true;   
					 this.form_data.city_id = this.dec.city_id;
					 this.changeCity(this.dec.city_id);	
					 this.form_data.county_id = this.dec.county_id;
						   
				 }
				 
				 // console.log('dec',this.dec);
			},
			async getToken(token){
				uni.setStorageSync('token','')
				const res = await this.$httpPub({
						  url:'user/token/' + token,
						  method:'get',
						  data:{ }
					})	
					
					if(res) {
						uni.setStorageSync('token',res.data);
						this.getRole();
						this.getCategory();
						this.getStudent();
						this.getAra();
						this.getAraBig();
						this.getdec();
						// this.getStudent()
					};
					// if(res) {
					// 	item.collect_id = res.id;
					// 	item.is_collect = 1;
					// 	this.toast('收藏成功')
					// }
				
				// uni.setStorageSync("token",token)
			},
			async getAra() {
				const res = await this.$httpPub({
					  url:'api/public/region',
					  method:'post',
					  data:{}
				},'lb')
				// console.log(res);
				this.rangeCity = res.map((item)=> {
					return {
						value:item.id,
						text:item.name
					}
				})
				this.rangeCity.unshift({
					text:'请选择',
					value:""
				})
				
			},
			async getAraBig() {
				const res = await this.$httpPub({
					  url:'api/public/region',
					  method:'post',
					  data:{}
				},'lb')
				// console.log(res);
				this.rangeBigCity = res.map((item)=> {
					return {
						value:item.id,
						text:item.name
					}
				})
				this.rangeBigCity.unshift({
					text:'请选择',
					value:""
				})
			},
			changeCity(e){
				//console.log(e);
				this.rangeSchool = [{text:'请先选择区县',value:""}];
				this.form_data.school_id = "";
				this.form_data.county_id = "";
				this.getCount(e);
			},
			changeBigCity(e){
				//console.log(e);
				// this.rangeSchool = [{text:'请先选择区县',value:""}];
				// this.form_data.school_big_id = "";
				// this.form_data.county_id = "";
				this.getBigCount(e);
			},
			async getCount(e) {
				this.form_data.school_id = "";
				const res = await this.$httpPub({
					  url:'api/public/region',
					  method:'post',
					  data:{
						  pid:e
					  }
				},'lb')
				// console.log(res);
				this.rangeCounty = res.map((item)=> {
					return {
						value:item.id,
						text:item.name
					}
				})
				this.rangeCounty.unshift({
					text:'请选择',
					value:""
				})
			},
			async getBigCount(e) {
				console.log('getBigCount');
				this.form_data.school_big_id = "";
				const res = await this.$httpPub({
					  url:'public/get_all_school?pid=' + e,
					  method:'get',
					  data:{ }
				})
				
				this.rangeBigSchool = res.map((item)=> {
					return {
						value:item.id,
						text:item.name
					}
				})
				this.rangeBigSchool.unshift({
					text:'请选择',
					value:""
				})
			},
			async changeCounty(e) {
				const res = await this.$httpPub({
					  url:'api/public/region',
					  method:'post',
					  data:{
						  county_id:e
					  }
				},'lb')
				this.rangeSchool = res.map((item)=> {
					return {
						value:item.id,
						text:item.name
					}
				})
				this.rangeSchool.unshift({
					text:'请选择',
					value:""
				})
			},
			async getCategory(){
				const res = await this.$httpPub({
					  url:'activity/category/'+ this.goid,
					  method:'get',
					  data:{}
				})
			   this.upTypeData = res.map((item) => {
				    // console.log(item);
					return {
						text:item.name,
						value:item.id,
						type:item.type,
						category:item.category
					 }
			   })
			   this.category = this.upTypeData[0].category;
			},
			async getRole(){
				const res = await this.$http({
					  url:'activity/role/' + this.goid,
					  method:'get',
					  data:{}
				})
				//console.log(res);
				const rangeRole = res.map((item) => {
					return {
						text:item.name,
						value:item.id,
						type:item.type,
						is_uni:item.is_uni,
						is_exist_teacher_article:item.is_exist_teacher_article
					}
				})
				
				console.log('rangeRole',res);
				
				this.role_data = rangeRole.filter((item) => {
					return item.is_exist_teacher_article == false
				});
				
				console.log('this.role_data',this.role_data);
				if(this.role_data.length < 1) {
					this.role_type = 99;
					
					// uni.showToast({
					// 	title:'您已经投稿成功了！',
					// 	icon:'none'
					// })
					// uni.navigateBack()
				} else {
					console.log(this.role_data[0]);
					this.role_type = this.role_data[0].type;
					this.is_uni = this.role_data[0].is_uni;
				}
				
				
				// console.log(this.role_data[0].is_uni);
 			},
			async getStudent() {
				const res = await this.$http({
					  url:'user/student/' + this.goid,
					  method:'get',
					  data:{}
				})
				// console.log(res);
				this.studata = res.data;
				// console.log(this.studata);
				// console.log(this.studata);
			},
			nextStep(){
				// console.log(this.role_type);
				if(this.role_type == 1) { //判断学生
					if(this.studata[this.currentStu].is_exist == 1) {
						uni.showToast({
							icon: 'none',
							title: '请选择有效学生'
						})
						return 
					}
				}
				// form_data:{
				// 	city_id:"",
				// 	county_id:"",
				// 	school_id:"",
				// 	school3:"",
				// 	name:'',
				// 	classname:"",
				// 	role_id:""
				// },
				if(this.role_type == 2) { //判断填入值
				  if(this.is_uni) {
					  if(!this.form_data.city_big_id) {
					  	this.toast('请选择地区')
					  	return
					  }
					  if(!this.form_data.school_big_id) {
					  	this.toast('请选择学校')
					  	return
					  }
					  if(!this.form_data.bigname) {
					  	this.toast('请输入姓名')
					  	return
					  }
				  } else {
					  if(!this.form_data.city_id) {
					  	this.toast('请选择地区')
					  	return
					  }
					  if(!this.form_data.county_id) {
					  	this.toast('请选择区县')
					  	return
					  }
					  if(!this.form_data.school_id) {
					  	this.toast('请选择学校')
					  	return
					  }
					  if(!this.form_data.name) {
					  	this.toast('请输入姓名')
					  	return
					  }
				  }
				}
				
				if(this.role_type == 3) { //判断填入值
				  if(this.is_uni) {
					  
					  if(!this.form_data.city_big_id) {
					  	this.toast('请选择地区')
					  	return
					  }
					  if(!this.form_data.school_big_id) {
					  	this.toast('请选择学校')
					  	return
					  }
					  if(!this.form_data.bigname) {
					  	this.toast('请输入姓名')
					  	return
					  }
				  } else {
					  if(!this.form_data.city_id) {
					  	this.toast('请选择地区')
					  	return
					  }
					  if(!this.form_data.county_id) {
					  	this.toast('请选择区县')
					  	return
					  }
					  
					  if(!this.form_data.name) {
					  	this.toast('请输入姓名')
					  	return
					  }
					  if(!this.form_data.name) {
					  	this.toast('请输入姓名')
					  	return
					  }
					  if(!this.form_data.school3) {
					  	this.toast('请输入单位或学校')
					  	return
					  }
				  }
				}
				
				this.step = 2;
			},
			
			choice(index,exit) {
				if(exit) {
					return
				}
				this.currentStu = index;
			},
			async deletStu(index) {
				const id = this.studata[index].student_id;
				// console.log(id);
				const res = await this.$http({
					url:"api/student/del_student",
					method:'post',
					data:{
						student_id:id
					}
				},'lb')
				
				if(res) {
					this.toast('操作成功')
					this.studata.splice(index,1)
				}
				return false;
			},
			addStudent(){
				uni.navigateTo({
					url:'/pages/addStu/addStu'
				})
			},
			getList(obj) {
				// upValue:{
				// 	img:[],
				// 	mp4:[],
				// 	word:[]
				// }
				if(obj.type == "mp4") {
					this.upValue.mp4 = obj.list;
				}
				if(obj.type == "word") {
					this.upValue.word = obj.list;
				}
				if(obj.type == "img") {
					this.upValue.img = obj.list;
				}
			
				// console.log('thisUpvalue',this.upValue);
			},
			blackStep() {
				this.step = 1;
			},
			changeRoles(index) {
				this.currentRoloIndex = index;
				this.role_type = this.role_data[index].type;
				this.is_uni = this.role_data[index].is_uni;
				this.form_data.city_id = "";
				this.form_data.school_id = '';
				this.form_data.county_id = '';
			},
			changeUpTab(index) {
				this.currentWorkTypeIndex = index;
				this.category = this.upTypeData[index].category;
				this.upValue.img = [];
				this.upValue.word = [];
                this.upValue.mp4 = [];
				this.$refs.oss.initList();
			},
			toat(str){
				uni.showToast({
					title:str,
					icon:'none'
				})
			},
			checkUp(array,msg1,msg2) {
				 let result = true
				// console.log(array);
				if(array.length == 0) {
					this.toat(msg1);
					result = false;
				} else {
					for(var i = 0;i < array.length; i++) {
					   if(!array[i].etag){
						   this.toat(msg1);
						   result = false;
						   break;
					   }
					}
					
				}
				return result;
			},
			async  allSubmit(){
				uni.showLoading({
					title: '加载中'
				});
				 var  file_data = [];
		        // debugger;
			     // console.log('提交',this.upValue);	
				 if(this.category.mp4) {
				 	let checkUp = this.checkUp(this.upValue.mp4,"请上传视频","请确保视频上传完成");
				 	if(!checkUp) {
				 		return
				 	}
				 }
				 
				 if(this.category.image) {
				 	let checkUp = this.checkUp(this.upValue.img,"请上传图片","请确保图片上传完成");
					if(!checkUp) {
						return
					}
				 }
				 
				 if(this.category.docs) {
				 	let checkUp = this.checkUp(this.upValue.word,"请上传文档","请确保文档上传完成");
				 	if(!checkUp) {
				 		return
				 	}
				 }
				
				 for(const key in this.upValue) {
				 	if(this.upValue[key].length > 0);
					this.upValue[key].src = '';
				 	file_data.push(...this.upValue[key])
				 }
				  
				  console.log('通过');
				  const activity_id = this.$route.query.id;
				  
				  if(!this.workName) {
				  	this.toast('请输入作品名称');
				  	return
				  }
				  if(!Phone.test(this.phone)) {
				  	this.toast('请输入正确手机号');
				  	return
				  }
				  // if(!this.address) {
				  // 	this.toast('请输入指导老师姓名');
				  // 	return
				  // }
				  
				  
					let role_id = this.role_data[this.currentRoloIndex].value;
					let role_user_id = ""
					let category_id  = this.upTypeData[this.currentWorkTypeIndex].value;
					let role2Form;
					if (this.role_type == 1) {
						role_user_id = this.studata[this.currentStu].student_id;
						role2Form = {};
					}
					
					if (this.role_type == 2) {
						role_user_id = 0;
						if (!this.is_uni) {
							role2Form = {
								role_username:this.form_data.name,
								role_city_id:this.form_data.city_id,
								role_county_id:this.form_data.county_id,
								role_school_id:this.form_data.school_id,
								role_schoolname:this.getSchoolName(this.form_data.school_id)
							}
						} else {
							role2Form = {
								role_colleges:this.form_data.role_colleges,
								role_major:this.form_data.role_major,
								role_username:this.form_data.bigname,
								role_city_id:this.form_data.city_big_id,
								role_school_id:this.form_data.school_big_id,
								role_schoolname:this.getSchoolName(this.form_data.school_big_id,"big")
							}
						}
					}
					if (this.role_type == 3) {
						role_user_id = 0;
						if (!this.is_uni) {
							role2Form = {
								role_username:this.form_data.name,
								role_city_id:this.form_data.city_id,
								role_county_id:this.form_data.county_id,
								role_school_id:this.form_data.school_id,
								role_schoolname:this.form_data.school3,
							}
						} else {
							role2Form = {
								role_colleges:this.form_data.role_colleges,
								role_major:this.form_data.role_major,
								role_username:this.form_data.bigname,
								role_city_id:this.form_data.city_big_id,
								role_school_id:this.form_data.school_big_id,
								role_schoolname:this.getSchoolName(this.form_data.school_big_id,"big")
							}
						}
					}
			      // form_data:{
			      // 	city_id:"",
			      // 	county_id:"",
			      // 	school_id:"",
			      // 	school3:"",
			      // 	name:'',
			      // 	classname:"",
			      // 	role_id:""
			      // },
				  // item.file_key.split(".")[1] == "MOV" ? 'mp4' : file_key.split(".")[1],
				  //console.log('234214234234234',file_data);
				  var newArray = file_data.map((item) => {  
					  var ext;
					  if(item.file_key.split(".")[1].toLowerCase() == 'mov') {
						  ext = 'mp4'
					  } else {
						  ext = item.file_key.split(".")[1];
					  }
					  //-console.log(ext);
					  return {
						  etag:item.etag,
						  ext:ext,
						  file_key:item.file_key,
						  id:item.id,
						  filename:item.filename
					  }
				  })
				  
				console.log('newArray',newArray);
				 let postdata = {
					 activity_id:activity_id,
					 title:this.workName,
					 file_data:JSON.stringify(newArray),
					 role_user_id:role_user_id,
					 guide_teacher:this.address,
					 mobile:this.phone,
					 role_id:role_id,
					 category_id:this.upTypeData[this.currentWorkTypeIndex].value,
					 ...role2Form
				 }
				
				//console.log(postdata);
                const res = await this.$http({
                	url:'article/save',
                	method:'post',
                	data:postdata
                })
				// console.log(res);
				if(res) {
					uni.hideLoading();
					this.toast('创建成功!');
					uni.redirectTo({
						url:'/pages/my/my?id=' + this.goid
					})
				} else {
					this.toast('创建失败!');
					uni.hideLoading();
				}
			},
			getSchoolName(id,big) {
				// debugger;
				// console.log(id);
				// console.log(this.rangeSchool);
				var name;
				if(big) {
					this.rangeBigSchool.forEach((item) => {
						 if(id == item.value) {
							 name = item.text
						 }
					})
				}else {
					this.rangeSchool.forEach((item) => {
						 if(id == item.value) {
							 name = item.text
						 }
					})
				}
				return name
			},
			toggleBtn(){
				this.open_off = !this.open_off;
			}
		}
	}
</script>

<style lang="scss">
	.block {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 34rpx 30rpx;
		margin-bottom: 23rpx;
	}

	.ad-name-inputBox {
		background-color: #f7f7f7;
		 height: 100rpx;
		 border-radius: 15rpx;
		 align-items: center;
		 display: flex;
		 font-size: 30rpx;
		 .uni-input-placeholder, input {
			  font-size: 30rpx;
		 }
	}
	
	
   #upLoad {
	   .tongyi {
		   .tongyi-icon {
			   width: 38rpx;
			   height: 38rpx;
			   vertical-align: text-bottom;
			   margin-right: 10rpx;
		   }
	   }
	   .upBox {
		   .upImgBox {
			   display: flex;
			   .default {
				   width: 156rpx;
				   height: 156rpx;
			   }
			   .upImgBtnlist {
				    display: flex;
					img {
						width: 156rpx;
						height: 156rpx;
						margin-right: 10rpx;
					}
			   }
		   }
		  
	   }
	   .add-form {
		   padding: 0;
		   .add-row {
			   background-color: #f7f7f7 !important;
			   &.school {
				    .ad-label { 
						width: 220rpx;
					}
					.ad-inputBox  {
						width: 444rpx;
					}
			   }
			   background-color: #fff;
			   display: flex;
			   border-radius: 16rpx;
			   margin-bottom: 16px;
			   .ad-label {
				 width: 280rpx;
				 height: 100rpx;
				 font-size: 28rpx;
				 @include center();
			   }
			   .ad-inputBox {
				 width: 544rpx;
				 height: 100rpx;
				 @include center();
			   }
		   }
	   }
	   padding: 23rpx 38rpx;
	   .title {
	   	font-weight: 550;
		 margin-bottom: 20rpx;
		 font-size: 32rpx;
	   }
	   .nextBtn {
		   padding: 50rpx 0;
		   @include bt-s-1();
	   }
	   .nextBtnTwo {
		   padding: 50rpx 20rpx !important;
		   @include bt-s-2();
	   }
	   .join {
		   .over {
			   color:#f24545;	
		   }
		   .btnbox {
			   font-size: 30rpx;
			   margin-bottom: 20rpx;
			   display: flex;
			   justify-content: space-between;
			   .addICon {
			   	vertical-align: text-top;
			   	margin-right: 10rpx;
			   }
		   }
		   .stus {
		   	.stu {
		   		padding: 40rpx;
		   		margin-bottom: 20rpx;
		   		background-color: #f7f7f7;
		   		border-radius: 10rpx;
		   		position: relative;
			    background-image: url("../../static/img/check.png");
				background-position: 550rpx 23rpx;
				background-repeat: no-repeat;
				.is_can {
				  background-color: #ff9200;
				  color:#fff;
				  position: absolute;
				  right: 0;
				  top:0;
				  border-radius: 0 10px 0 10px;
				  padding: 4rpx 10rpx;
				  display: none;
				}
				&.active {
					 background-image: url("../../static/img/checked.png");
				}
		   		 &.join {
				  background-image: none;
				  .is_can {
					display: block;
		
				  }
				}
		   		
		   		.iconfont {
		   			font-size: 46rpx;
		   		}
		   		.st-title {
		   			margin-bottom: 15rpx;
		   			font-weight: 550;
		   			font-size: 30rpx;
					display: flex;
					.ycy {
						position: absolute;
						right: 0;
						top:0;
						background-color: #ff9200;
						color:#fff;
						padding: 12rpx 20rpx;
						border-radius: 0 20rpx 0 20rpx;
					}
					.name {
						margin-right: 10rpx;
					}
		   		}
		   		.textell {
		   			font-size: 28rpx;
		   			padding-top: 10rpx;
		   		}
		   	}
		   	
		   }
	   }
	   .roles {
		   display: flex;
		   flex-wrap: wrap;
		   .role {
			   flex:none;
			   background-color: #f24545;
			   color:#fff;
			   border-radius: 8rpx;
			   font-size: 28rpx;
			   padding: 10rpx  16rpx;
			   margin-right: 30rpx;
			   opacity: 0.5;
			   margin-bottom: 10rpx;
			   &.active {
				   opacity: 1;
			   }
		   }
	   }
	   .info {
		     padding-bottom: 20rpx;
		   .f-title {
			   color:#f24545;
			   font-size: 28rpx;
			   width: 162rpx;
			   padding-left: 15rpx;
			   height: 24rpx;
			   line-height: 0.8;
			   border-left: 2px solid #f24545;
			   margin-bottom: 20rpx;
		   }
		   .infoText {
			   font-size: 29rpx;
			   position: relative;
			   &.close {
				   height: 120rpx;
				   overflow: hidden;
			   }
		   }
		   .toggleBtn {	   
			   background-color: #fff;
			   font-size: 29rpx;
			   width: 100%;
			   text-align: center;
			   padding-top: 10rpx;
			   .icon-warning {
				   margin-left: 10rpx;
				   font-weight: 550;
			   }
		   }
	   }
   }
</style>
